<div id="main_content">
    <h3><?php echo $title; ?></h3>
    <div class="form_search wrapFrmEmploryeSearch">
        <table width="100%" >
            <tr>
                <td width="100%" >
                    <form name="frmEmploryeSearch" class="frmEmploryeSearch" method="POST" action="">
                        <label class="lblName"><?php echo $frm_lblName; ?></label><input type="text" class="txtName" name="txtName" value="<?php echo dQuotes($this->input->post('txtName')); ?>" maxlength="255"/>  
                        <label class="lblEmail"><?php echo $frm_lblEmail; ?></label><input type="text" class="txtEmail" name="txtEmail" value="<?php echo dQuotes($this->input->post('txtEmail')); ?>" maxlength="255"/>
                        <label class="lblPosition"><?php echo $frm_lblPosition; ?></label>
                        <select class="cboPosition cmbPosition" name="cboPosition">
                            <option value=""><?php echo $nullcharacter; ?></option>
                            <?php if (count($position)): ?>
                                <?php foreach ($position as $item) { ?>
                                    <option value="<?php echo $item->PositionId; ?>" <?php echo (($item->PositionId == $this->input->post('cboPosition')) ? 'selected' : ''); ?>><?php echo dQuotes($item->PositionName); ?></option>
                                <?php } ?>
                            <?php endif; ?>
                        </select>
                        <input type="submit" value="<?php echo $frm_btnSearch; ?>"  class="btnSearch search"  name="btnSearch" />
                    </form>
                </td>
            </tr>
        </table>
    </div>
    <div class="clr"></div>
    <a href="<?php echo base_url(); ?>employee/update" class="new_regis"><?php echo $newRegister; ?></a>
    <div class="table_list employeeList">
        <table border="0" width="100%"  class="list_view_data" cellpadding="0" cellspacing="0">
            <thead>
                <tr align="center">
                    <th width="5%"><?php echo $table_col_id; ?></th>
                    <th width="10%"><?php echo $table_col_fullName; ?></th>
                    <th width="8%"><?php echo $table_col_dateOfBirth; ?></th>
                    <th width="10%"><?php echo $table_col_IDCardNo; ?></th>
                    <th width="10%"><?php echo $table_col_email; ?></th>
                    <th width="5%"><?php echo $table_col_position; ?></th>
                    <th width="10%"><?php echo $table_col_grossSalary; ?></th>
                    <th width="10%"><?php echo $table_col_bonus; ?></th>
                    <th width="10%"><?php echo $table_col_noOfDependant; ?></th>
                    <th width="10%" class="col_leaveLeft"><?php echo $table_col_leaveLeft; ?></th>
                    <th width="7%"><?php echo $table_col_joinDatee; ?></th>
                    <th width="5%"><?php echo $table_col_status; ?></th>
                    <th width="5%"><?php echo $table_col_active; ?></th>                                
                </tr>
            </thead>
            <tbody>
                <?php if (count($data)): ?>
                    <?php foreach ($data as $item): ?>
                        <tr>
                            <td align="center"><div class="table_col table_col_id"><?php echo ++$order; ?></div></td>
                            <td align="left"><div class="table_col table_col_fullName"><a title="<?php echo dQuotes($item->EmployeeName); ?>" href="<?php echo base_url('/employee/update/'); ?>" data-employeeID="<?php echo $item->EmployeeId; ?>"><?php echo subString(dQuotes($item->EmployeeName), 20); ?></a></div></td>
                            <td align="center"><div class="table_col table_col_dateOfBirth"><?php echo ($item->DateOfBirth == '0000-00-00') ? $nullcharacter : date('Y/m/d', strtotime($item->DateOfBirth)); ?></div></td>
                            <td align="center"><div class="table_col table_col_IDCardN" title="<?php echo dQuotes($item->IdCardNumber); ?>"><?php echo subString(dQuotes($item->IdCardNumber)); ?></div></td>
                            <td align="center"><div class="table_col table_col_email" title="<?php echo ($item->Email == '') ? $nullcharacter : dQuotes($item->Email); ?>"><?php echo ($item->Email == '') ? $nullcharacter : subString(dQuotes($item->Email), 25); ?></div></td>
                            <td align="center">
                                <?php if (count($position)): ?>
                                    <?php foreach ($position as $itemP) { ?>
                                        <?php if ($itemP->PositionId == $item->PositionId) { ?>
                                            <div class="table_col table_col_position" title="<?php echo dQuotes($itemP->PositionName); ?>"><?php echo subString(dQuotes($itemP->PositionName), 5); ?></div>
                                        <?php } ?>
                                    <?php } ?>
                                <?php endif; ?>
                            </td>
                            <td align="center"><div class="table_col table_col_grossSalary"><a href="<?php echo base_url('/employee/salary-info'); ?>" data-employeeID="<?php echo $item->EmployeeId; ?>"><?php echo (($item->grossSalary) ? $item->grossSalary : $nullcharacter); ?></a></div></td>
                            <td align="center"><div class="table_col table_col_bonus"><a href="<?php echo base_url('/employee/bonus'); ?>" data-employeeID="<?php echo $item->EmployeeId; ?>"><?php echo (($item->bonus) ? $item->bonus : $nullcharacter); ?></a></div></td>
                            <td align="center"><div class="table_col table_col_noOfDependant"><a href="<?php echo base_url('/employee/pit-info'); ?>" data-employeeID="<?php echo $item->EmployeeId; ?>"><?php echo (($item->dependants) ? $item->dependants : $nullcharacter); ?></a></div></td>
                            <td align="center"><div class="table_col table_col_leaveLeft"><a href="<?php echo base_url('/employee/leave-info'); ?>" data-employeeID="<?php echo $item->EmployeeId; ?>"><?php echo (($item->leaveLeft) ? $item->leaveLeft : $nullcharacter); ?></a></div></td>
                            <td align="center"><div class="table_col table_col_joinDatee"><?php echo ($item->JoinDate == '0000-00-00') ? $nullcharacter : date('Y/m/d', strtotime($item->JoinDate)); ?></div></td>  
                            <td align="center"><div class="table_col table_col_status">
                                    <img src="<?php echo ($item->Status) ? base_url('/public/sites/images/check-icon.png') : base_url('/public/sites/images/uncheck.gif'); ?>" width="15">
                                </div>
                            </td>
                            <td align="center"><div class="table_col table_col_status">
                                    <img src="<?php echo ($item->Del_Flag) ? base_url('/public/sites/images/uncheck.gif') : base_url('/public/sites/images/check-icon.png'); ?>" width="15">
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                <?php endif ?>
            </tbody>
        </table>
    </div>
    <?php if (!count($data)): ?>
        <div class="clr"></div>
        <div class="errormessage"><?php echo $message; ?></div>
    <?php endif ?>
    <div class="clr"></div>
    <div class="pagination"><?php echo $pagi; ?></div>
</div>
<div class="clr"></div>
<div class="redirectTo">
    <form class="frmRedirectTo" class="frmRedirectTo" name="frmRedirectTo" action="" method="POST">
        <input type="hidden" name="txtEmployeeId" class="employeeID" value="0">
    </form>
</div>
<script type="text/javascript">
    $(document).ready(function() {
        /*when click pagination*/
        $('.pagination a').click(function(e) {
            e.preventDefault();
            var url = $(this).attr('href');
            if (url != 'javascript:void(0)') {
                $('.frmEmploryeSearch').attr('action', url);
                $('.frmEmploryeSearch').submit();
            }
        });
        
        /*change link action to post action*/
        $('.table_col a').click(function(e) { 
            e.preventDefault();
            var url = $(this).attr('href'); 
            var employeeID = $(this).attr('data-employeeID');
            $('.frmRedirectTo').attr('action', url);
            $('.employeeID').val(employeeID); 
            $('.frmRedirectTo').submit();
        });
        
        /*when click search*/
        $('.btnSearch').click(function(e) {
            e.preventDefault();
            $('.frmEmploryeSearch').attr('action', '/employee');
            $('.frmEmploryeSearch').submit();
        });
        
    });
</script>